task get_last_max_day (input reg [7:0] month, output reg [7:0] last_max_day);

  begin
    case(month)
        6'd1 : last_max_day = 6'd31; 
        6'd2 : last_max_day = 6'd31;
        6'd3 : last_max_day = 6'd28;
        6'd4 : last_max_day = 6'd31;
        6'd5 : last_max_day = 6'd30;
        6'd6 : last_max_day = 6'd31;
        6'd7 : last_max_day = 6'd30;
        6'd8 : last_max_day = 6'd31;
        6'd9 : last_max_day = 6'd31;
        6'd10 : last_max_day = 6'd30;
        6'd11 : last_max_day = 6'd31;
        6'd12 : last_max_day = 6'd30;
    endcase
end
endtask


task dec_day(input reg [7:0] day_in, input reg [7:0] last_max_day, output reg [7:0] day_out, output reg [7:0] carry_day);

begin
    if(day_in == 1) begin
        day_out = last_max_day;
        carry_day = 1'b1;
    end else begin
        day_out = day_in - 1;
        carry_day = 1'b0;
    end
end
endtask

task dec_month (input carry_day, input reg [7:0] month_in, output reg [7:0] month_out,  output carry_month);

  if (carry_day) begin
    if (month_in == 1) begin
      month_out = 12;
      carry_month = 1'b1;
    end
    else begin
      month_out = month_in - 1;
      carry_month = 1'b0;
    end
  end 
  else begin
    month_out = month_in;
  end
endtask

task dec_year(input carry_month, input reg [11:0] year_in, output reg [11:0] year_out);

  if (carry_month) begin
    year_out = year_in - 1;
  end
  else year_out = year_in;

endtask

